import { View } from "@tarojs/components";

import ByCol from "@/components/ui/ByCol";
import ByRow from "@/components/ui/ByRow";
import ByText from "@/components/ui/ByText";
import ListView from "@/components/app/ListView";
import Attendance from "@/packageProject/components/Attendance";

import ApiCrm from "@/api/crm";
import useFetch from "@/hooks/useFetch";
/**
 * 生活费
 */
const LivingExpensesItem = ({
  source,
}: {
  source;
  checked?: boolean;
}) => {
  return (
    <ByRow align="center" className="rounded-lg m-3 shadow-black-1" >

      <ByCol span={"auto"} className="ml-2">
        <View
          className={`rounded-xl p-3 border-primary border-1 bg-white border-white`}
        >
          <ByRow align="center" content="between">
            <ByCol span={"none"}>
              <ByText bold size="lg">
                {source?.workerName}
              </ByText>
              <View className="mt-2 text-second text-sm">
                {source?.workerType}
              </View>
            </ByCol>
            <ByCol span={"none"}>
              <Attendance source={source} />
            </ByCol>
          </ByRow>
        </View>
      </ByCol>
    </ByRow>
  );
};

// 生活费
export default ({ intentCustomerId }: { intentCustomerId: number }) => {

  // 考勤记录
  const { data } = useFetch<any>(ApiCrm.getWorkerAttendanceRecord, {
    defaultParams: [{ intentCustomerId }],
  });


  // 工人列表
  const workers = data?.workerAttendanceRecordList || []

  return (
    <>
      <ListView isEmpty={workers.length === 0}>
        {workers?.map((item) => (
          <LivingExpensesItem
            source={item}
            key={item.workerDistributeId}
          />
        ))}
      </ListView>
    </>
  );
};
